package com.newsproject.mapper;

import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface GetAnnouncementMapper {
    // 查询time时间之后的新增的私信数量
    @Select("SELECT COUNT(message_id) FROM private_message WHERE receiver_id = #{userId} AND created_time >= #{time}")
    public int getPrivateMessageCount(@Param("userId")int userId,@Param("time") String time);

    // 查询time时间之后的新增的评论数量
    @Select("SELECT COUNT(comment_id) FROM comment WHERE post_id IN (SELECT post_id FROM post WHERE user_id = #{userId}) AND created_time >= #{time}")
    public int getCommentCount(@Param("userId")int userId,@Param("time") String time);

    // 查询time时间之后的新增的@我的数量
    @Select("SELECT COUNT(at_id) FROM at WHERE receiver_id = #{userId} AND created_time >= #{time}")
    public int getAtMeCount(@Param("userId")int userId,@Param("time") String time);

    // 查询time时间之后的新增的评论点赞数量
    @Select("SELECT COUNT(comment_like_id) FROM comment_like WHERE comment_id IN (SELECT comment_id FROM comment WHERE post_id IN (SELECT post_id FROM post WHERE user_id = #{userId})) AND created_time >= #{time}")
    public int getCommentLikeCount(@Param("userId")int userId,@Param("time") String time);

    // 查询time时间之后的新增的新闻点赞数量
    @Select("SELECT COUNT(like_id) FROM heart WHERE post_id IN (SELECT post_id FROM post WHERE user_id = #{userId}) AND created_time >= #{time}")
    public int getNewsLikeCount(@Param("userId")int userId,@Param("time") String time);

    // 查询time时间之后的粉丝变化数量
    @Select("SELECT COUNT(follow_id) FROM follow WHERE followed_id = #{userId} AND created_time >= #{time}")
    public int getFansChangeCount(@Param("userId")int userId,@Param("time") String time);

}
